package com.itheima.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.itheima.dto.WarehouseAreaLocaDTO;
import com.itheima.pojo.WarehouseAreaLoca;
import com.itheima.service.WarehouseAreaLocaService;
import com.itheima.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/warehouseAreaLoca")
public class WarehouseAreaLocaController {
    @Autowired
    private WarehouseAreaLocaService warehouseAreaLocaService;

    @GetMapping("/page")
    public Page<WarehouseAreaLocaDTO> getWarehouseAreaLocaPage(Page<WarehouseAreaLocaDTO> page, WarehouseAreaLocaDTO dto) {
        return warehouseAreaLocaService.getWarehouseAreaLocaPage(page, dto);
    }

    @GetMapping("/{id}")
    public Result getWarehouseAreaLocaById(@PathVariable Integer id) {
        return Result.success(warehouseAreaLocaService.getWarehouseAreaLocaById(id));
    }

    @PostMapping
    public Result saveWarehouseAreaLoca(@RequestBody WarehouseAreaLoca warehouseAreaLoca) {
        return Result.success(warehouseAreaLocaService.saveWarehouseAreaLoca(warehouseAreaLoca));
    }

    @PutMapping
    public Result updateWarehouseAreaLoca(@RequestBody WarehouseAreaLoca warehouseAreaLoca) {
        return Result.success(warehouseAreaLocaService.updateWarehouseAreaLoca(warehouseAreaLoca));
    }

    @DeleteMapping("/{id}")
    public Result deleteWarehouseAreaLoca(@PathVariable Integer id) {
        return Result.success(warehouseAreaLocaService.deleteWarehouseAreaLoca(id));
    }
}
